package Demo01;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28463
 * Date: 2022—05—30
 * Time: 13:18
 */
public class Test03 {
    public static int func(int a) {
        try{
            if(a == 0) {
                throw  new ArithmeticException();
            }
            return a;
        } catch (ArithmeticException e) {
            System.out.println("算术异常！");
        } finally {
            return 20;
        }
    }

    public static void main(String[] args) {
        System.out.println(func(10));
    }
/*        try (Scanner scanner = new Scanner(System.in)) {
            int[] array = {1, 2, 3};
            System.out.println(array.length);
        } catch (NullPointerException e) {
            System.out.println("捕获到了一个空指针异常！");
        } catch (ArithmeticException e) {
            System.out.println("捕获到了一个算术异常！");
        } finally {
            System.out.println("进行资源关闭！");
        }
        System.out.println("其它代码逻辑！");
    }*/
}
